package com.xxx.entity;

import lombok.Data;

@Data
public class RE<T> {

    private int code;
    private String message;
    private T date;


    public RE(){
        this.code=200;
        this. message="success";
    }

    public static RE error() {
        return error(500, "未知异常，请联系管理员");
    }

    public static RE error(String msg) {
        return error(500, msg);
    }

    public static RE error(int code, String message) {
        RE re = new RE();
        re.code = code;
        re.message = message;
        return re;
    }

    public RE<T> error(T t) {
        RE re = error(500, "未知异常，请联系管理员");
        re.setDate(t);
        return re;
    }

    public static RE ok(String message) {
        RE re = new RE();
        re.code = 0;
        re.message = message;
        return re;
    }

    public RE<T> ok(T t) {
        RE re = new RE();
        re.date = t;
        return re;
    }

    public static RE ok() {
        return new RE();
    }
}
